package com.xnx3.banmahuishou.userApplet.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xnx3.banmahuishou.userApplet.vo.CarouselImageListVO;
import com.xnx3.j2ee.controller.BaseController;
import com.xnx3.j2ee.service.SqlService;
import com.xnx3.j2ee.util.ActionLogUtil;
import com.xnx3.wangmarket.shop.core.entity.CarouselImage;

/**
 * 轮播图相关
 * @author 王晓龙
 */
@Controller(value="BanmahuishouUserAppletCarouselImageController")
@RequestMapping("/userApplet/carouselImage/")
public class CarouselImageController extends BaseController {
	@Resource
	private SqlService sqlService;
	
	/**
	 * 获取轮播图列表
	 * @author 王晓龙
	 */
	@ResponseBody
	@RequestMapping(value="list.json",method= {RequestMethod.POST})
	public CarouselImageListVO list(HttpServletRequest request){
	    //创建查询语句
	    String sql = "SELECT * FROM shop_carousel_image ORDER BY rank ASC";
	    //因只查询的一个表，所以可以将查询结果转化为实体类，用List接收。
	    List<CarouselImage> list = sqlService.findBySqlQuery(sql, CarouselImage.class);
	    CarouselImageListVO vo = new CarouselImageListVO();
	    vo.setList(list);
	    ActionLogUtil.insert(request, "获取轮播图列表", "轮播图列表"+list.toString());
	    return vo;
	}
}
